package xyz.zcq.example.consumer;

import xyz.zcq.example.common.model.User;
import xyz.zcq.example.common.service.UserService;
import xyz.zcq.zcqrpc.RpcApplication;
import xyz.zcq.zcqrpc.bootstrap.ConsumerBootstrap;
import xyz.zcq.zcqrpc.config.RpcConfig;
import xyz.zcq.zcqrpc.proxy.ServiceProxyFactory;

/**
 * 服务消费者示例
 */
public class ConsumerExample {

    public static void main(String[] args) {
//        RpcConfig rpcConfig = RpcApplication.getRpcConfig();
//        System.out.println(rpcConfig);
        ConsumerBootstrap.init();

//        UserService userService = new UserServiceProxy();
        UserService userService = ServiceProxyFactory.getProxy(UserService.class);

        User u = new User("zcq");
            User user = userService.getUser(u);

        if (user != null) {
            System.out.println(user.getName());
        } else {
            System.out.println("user is null");
        }

        int number = userService.getNumber();
        System.out.println("number = " + number);

    }

}
